/** include config.h **/
#include "config.h"

#ifdef ENABLE_MYSQL


#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>



#ifdef WINDOWS
    #pragma comment (lib,"libmysql.lib")
    #pragma comment (lib,"mysqlclient.lib")
#endif
#include <mysql.h>

#include "AbstractDatabase.h"

class MySQLDatabase : public AbstractDatabase{
public:
    /** Constructor and Database Connection **/
	MySQLDatabase(PString host, PString port, PString database, PString user, PString password);
	virtual ~MySQLDatabase();
	bool isConnected(String database);

	/** Query **/
    PQuery query(String sqlQuery);
    PQuery select(PString database, PString schema, PString table, int option = OPTION_ALL);
	PQuery getTableInfoQuery(PString database, PString schema, PString table);
	PQuery getFieldListQuery(PString database, PString schema, PString table);

	/** List Databases, Schemata and Tables **/
	PQuery listDatabases();
	PQuery listSchemata(PString database);
    PQuery listTables(PString database, PString schema);

    void dropTable(PString database, PString schema, PString table);

    /** Exists: Table, Database, Schema**/
    bool exists(PString database, PString schema, PString table);

    /** Other Query **/
    void rename(String oldname, String newname);
protected:
	MYSQL *conn;
	String supportGeoDataTypes;
	bool connected;
	friend class MySQLQuery;
};

#endif
